//
//  YQIdentityView.m
//  industry
//
//  Created by 王雅强 on 2021/2/4.
//  Copyright © 2021 Haier. All rights reserved.
//

#import "YQIdentityView.h"

@interface YQIdentityView()

@property (nonatomic, strong) XLButton *but;
@property (nonatomic, strong) XLButton *selectBut;


@end

@implementation YQIdentityView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setBounds:CGRectMake(0, 0, 77, 67)];
        
        [self addSubview:self.but];
        [self addSubview:self.selectBut];
        
        [self.but mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.left.centerY.equalTo(self);
        }];
        [self.selectBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.equalTo(self);
        }];
        
    }
    return self;
}

- (void)setSelected:(BOOL)selected{
    _selected = selected;
    self.selectBut.selected = selected;
}

- (void)setSelect{
    self.selected = !self.selected;
}



- (XLButton *)but
{
    if(!_but) {
        _but = ({
            XLButton * but = [[XLButton alloc] init];
            [but setImage:XLIMAGE(@"identity") forState:UIControlStateNormal];
            [but setTitle:@"员工登录" forState:UIControlStateNormal];
            [but setBounds:CGRectMake(0, 0, 56, 67)];
            [but.titleLabel setFont:[UIFont systemFontOfSize:14]];
            [but verticalImageAndTitle:7];
            [but setTitleColor:[UIColor colorWithHex:0x353535] forState:UIControlStateNormal];
            [but setButtonAction:^(XLButton * _Nonnull button) {
                [self setSelect];
            }];
            but;
        });
    }
    return _but;
}

- (XLButton *)selectBut
{
    if(!_selectBut) {
        _selectBut = ({
            XLButton * selectBut = [[XLButton alloc] init];
            [selectBut setImage:XLIMAGE(@"check_n") forState:UIControlStateNormal];
            [selectBut setImage:XLIMAGE(@"check_s") forState:UIControlStateSelected];
            [selectBut setButtonAction:^(XLButton * _Nonnull button) {
                [self setSelect];
            }];
            
            selectBut;
        });
    }
    return _selectBut;
}

@end
